package handling.opcode

import handling.WritableIntValueHolder

enum class PartyOpcode(private var type: Short) : WritableIntValueHolder {

    PartyReq_LoadParty(0),
    PartyReq_CreateNewParty(1),
    PartyReq_WithdrawParty(2),
    PartyReq_JoinParty(3),
    PartyReq_InviteParty(4),
    PartyReq_InviteIntrusion(5),
    PartyReq_KickParty(6),
    PartyReq_ChangePartyBoss(7),
    PartyReq_ApplyParty(8),
    PartyReq_SetAppliable(9),
    PartyReq_ClearIntrusion(10),
    PartyReq_CreateNewParty_Group(11),
    PartyReq_JoinParty_Group(12),
    PartyReq_PartySetting(13),
    PartyReq_LoadStarPlanetPoint(14),
    PartyRes_LoadParty_Done(19),
    PartyRes_CreateNewParty_Done(20),
    PartyRes_CreateNewParty_AlreayJoined(21),
    PartyRes_CreateNewParty_Beginner(22),
    PartyRes_CreateNewParty_Unknown(23),
    PartyRes_CreateNewParty_byNonBoss(24),
    PartyRes_WithdrawParty_Done(25),
    PartyRes_WithdrawParty_NotJoined(26),
    PartyRes_WithdrawParty_Unknown(27),
    PartyRes_JoinParty_Done(28),
    PartyRes_JoinParty_Done2(29),
    PartyRes_JoinParty_AlreadyJoined(30),
    PartyRes_JoinParty_AlreadyFull(31),
    PartyRes_JoinParty_OverDesiredSize(32),
    PartyRes_JoinParty_UnknownUser(33),
    PartyRes_JoinParty_Unknown(34),
    PartyRes_JoinIntrusion_Done(36),
    PartyRes_JoinIntrusion_UnknownParty(37),
    PartyRes_InviteParty_Sent(38),
    PartyRes_InviteParty_BlockedUser(39),
    PartyRes_InviteParty_AlreadyInvited(40),
    PartyRes_InviteParty_AlreadyInvitedByInviter(41),
    PartyRes_InviteParty_Rejected(42),
    PartyRes_InviteParty_Accepted(43),
    PartyRes_InviteIntrusion_Sent(45),
    PartyRes_InviteIntrusion_BlockedUser(46),
    PartyRes_InviteIntrusion_AlreadyInvited(47),
    PartyRes_InviteIntrusion_AlreadyInvitedByInviter(48),
    PartyRes_InviteIntrusion_Rejected(49),
    PartyRes_InviteIntrusion_Accepted(50),
    PartyRes_KickParty_Done(51),
    PartyRes_KickParty_FieldLimit(51),
    PartyRes_KickParty_Unknown(52),
    PartyRes_ChangePartyBoss_Done(55),
    PartyRes_ChangePartyBoss_NotSameField(56),
    PartyRes_ChangePartyBoss_NoMemberInSameField(57),
    PartyRes_ChangePartyBoss_NotSameChannel(58),
    PartyRes_ChangePartyBoss_Unknown(59),
    PartyRes_AdminCannotCreate(60),
    PartyRes_AdminCannotInvite(61),
    PartyRes_InAnotherWorld(62),
    PartyRes_InAnotherChanelBlockedUser(63),
    PartyRes_UserMigration(64),
    PartyRes_ChangeLevelOrJob(65),
    PartyRes_UpdateShutdownStatus(66),
    PartyRes_SetAppliable(68),
    PartyRes_SetAppliableFailed(69),
    PartyRes_SuccessToSelectPQReward(70),
    PartyRes_FailToSelectPQReward(71),
    PartyRes_ReceivePQReward(72),
    PartyRes_FailToRequestPQReward(73),
    PartyRes_CanNotInThisField(74),
    PartyRes_ApplyParty_Sent(75),
    PartyRes_ApplyParty_UnknownParty(76),
    PartyRes_ApplyParty_BlockedUser(77),
    PartyRes_ApplyParty_AlreadyApplied(78),
    PartyRes_ApplyParty_AlreadyAppliedByApplier(15),
    PartyRes_ApplyParty_AlreadyFull(80),
    PartyRes_ApplyParty_Rejected(81),
    PartyRes_ApplyParty_Accepted(82),
    PartyRes_FoundPossibleMember(83),
    PartyRes_FoundPossibleParty(84),
    PartyRes_PartySettingDone(85),
    PartyRes_Load_StarGrade_Result(89),
    PartyRes_Load_StarGrade_Result2(90),
    PartyRes_Member_Rename(91),
    PartyInfo_TownPortalChanged(93),
    PartyInfo_OpenGate(92),
    PP_NO(126);

    override fun getValue(): Short {
        return type
    }

    override fun setValue(newval: Short) {
        type = newval
    }

    companion object {
        fun getByAction(type: Short): PartyOpcode? {
            return PartyOpcode.values().firstOrNull { it.type == type }
        }
    }

}